<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>浅克隆/浅复制/浅拷贝</title>
</head>
<body>
  <!-- 
    实现浅拷贝
        方法一: 利用ES6语法
        方法二: 利用ES5语法: for...in
  -->
  <script src="../dist/atguigu-utils.js"></script>
  <script>
    const obj1 = { x: 'abc', y: {m: 1} }
    // const obj2 = aUtils.clone1(obj1)
    const obj2 = aUtils.clone2(obj1)
    console.log(obj2, obj2===obj1, obj2.x===obj1.x, obj2.y===obj1.y)

    const arr1 = ['abc', {m: 1}]
    // const arr2 = aUtils.clone1(arr1)
    const arr2 = aUtils.clone2(arr1)
    console.log(arr2, arr2===arr1, arr2[0]===arr1[0], arr2[1]===arr1[1])
  </script>
</body>
</html>